package com.xingkeduo.remote;

import com.alibaba.fastjson.JSON;
import com.xingkeduo.dto.StoreStaffVo;
import com.xingkeduo.remote.feign.WordPadFeignService;
import com.xingkeduo.utils.ResponseMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;


@Service
@Slf4j
public class WordPadRemoteService {

    @Resource
    private WordPadFeignService wordPadFeignService;

   public Set<Long>  getAdminIds(String storeId){
       ResponseMessage responseMessage =  wordPadFeignService.getStoreStaffList(Long.valueOf(storeId));
       log.info("responseMessage:{}", responseMessage);
       if(responseMessage.getStatus()==1 && responseMessage.getData()!=null){
           List<StoreStaffVo> storeStaffVos = JSON.parseArray(JSON.toJSONString(responseMessage.getData()), StoreStaffVo.class);
           Set<Long> admins = storeStaffVos.stream().map(StoreStaffVo::getStaffId).collect(Collectors.toSet());
           return admins;

       }
       return new HashSet<>();
   }

}
